home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWTPtrSet<T,C> - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include <rw/tpset.h> RWTPtrSet<T,C> s; SSSSttttaaaannnnddddaaaarrrrdddd CCCC++++++++ LLLLiiiibbbbrrrraaaarrrryyyy DDDDeeeeppppeeeennnnddddeeeennnntttt!!!! RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt requires the Standard C++ Library. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn This class maintains a pointer-based collection of values, which are ordered according to a comparison object of type CCCC. Class TTTT is the type pointed to by the items in the collection. CCCC must induce a total ordering on elements of type TTTT via a public member bool operator()(const T& x, const T& y) which returns ttttrrrruuuueeee if xxxx should precede yyyy within the collection. The structure lllleeeessssssss<<<<TTTT>>>> from the C++-standard header file <<<<ffffuuuunnnnccccttttiiiioooonnnnaaaallll>>>> is an example. Note that items in the collection will be dereferenced before being compared. RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt<<<<TTTT,,,,CCCC>>>> will not accept an item that compares equal to an item already in the collection. (RRRRWWWWTTTTPPPPttttrrrrMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>> may contain multiple items that compare equal to each other.) Equality is based on the comparison object and not on the ======== operator. Given a comparison object ccccoooommmmpppp, items aaaa and bbbb are equal if !comp(a,b) && !comp(b,a). PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee Isomorphic. EEEExxxxaaaammmmpppplllleeeessss In this example, a pointer-based set of RRRRWWWWCCCCSSSSttttrrrriiiinnnnggggs is exercised. PPPPaaaaggggeeee 1111 RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) // //tpset.cpp // #include <rw/tpset.h> #include <rw/cstring.h> #include <iostream.h> #include <function.h> main(){ RWTPtrSet<RWCString, less<RWCString> > set; set.insert(new RWCString("one")); set.insert(new RWCString("two")); set.insert(new RWCString("three")); set.insert(new RWCString("one")); // Rejected: duplicate entry cout << set.entries() << endl; // Prints "3" set.clearAndDestroy(); cout << set.entries() << endl; // Prints "0" return 0; } RRRReeeellllaaaatttteeeedddd CCCCllllaaaasssssssseeeessss Class RRRRWWWWTTTTPPPPttttrrrrMMMMuuuullllttttiiiiSSSSeeeetttt<<<<TTTT,,,,CCCC>>>> offers the same interface to a pointer-based collection that accepts multiple items that compare equal to each other. RRRRWWWWTTTTPPPPttttrrrrMMMMaaaapppp<<<<KKKK,,,,TTTT,,,,CCCC>>>> is a pointer-based collection of key-value pairs. Class sssseeeetttt<<<<TTTT****,,,,rrrrwwww____ddddeeeerrrreeeeffff____ccccoooommmmppppaaaarrrreeee<<<<CCCC,,,,TTTT>>>>,,,,aaaallllllllooooccccaaaattttoooorrrr>>>> is the C++-standard collection that serves as the underlying implementation for RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>. PPPPuuuubbbblllliiiicccc TTTTyyyyppppeeeeddddeeeeffffssss typedef rw_deref_compare<C,T> container_comp; typedef set<T*, container_comp,allocator> container_type; typedef container_type::size_type size_type; typedef container_type::difference_type difference_type; typedef container_type::iterator iterator; typedef container_type::const_iterator const_iterator; typedef T* value_type; typedef T*const& reference; typedef T*const& const_reference; PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>(const container_comp& comp = container_comp()); Constructs an empty set. RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>(const RWTPtrSet<T,C>& rws); Copy constructor. PPPPaaaaggggeeee 2222 RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>(const container_type& s); Creates a pointer based set by copying all elements from s. RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt<<<<TTTT,,,,CCCC>>>>(T* const* first,T* const* last,const container_comp& comp = container_comp()); Constructs a set by copying elements from the array of TTTT****s pointed to by ffffiiiirrrrsssstttt, up to, but not including, the element pointed to by llllaaaasssstttt. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss RWTPtrSet<T,C>& ooooppppeeeerrrraaaattttoooorrrr====(const container_type& s); RWTPtrSet<T,C>& ooooppppeeeerrrraaaattttoooorrrr====(const RWTPtrSet<T,C>& s); Clears all elements of self and replaces them by copying all elements of ssss. bool ooooppppeeeerrrraaaattttoooorrrr<<<<(const RWTPtrSet<T,C>& s); Returns ttttrrrruuuueeee if self compares lexicographically less than ssss, otherwise returns ffffaaaallllsssseeee. Items in each collection are dereferenced before being compared. Assumes that type TTTT has well-defined less-than semantics. bool ooooppppeeeerrrraaaattttoooorrrr========(const RWTPtrSet<T,C>& s); Returns ttttrrrruuuueeee if self compares equal to ssss, otherwise returns ffffaaaallllsssseeee. Two collections are equal if both have the same number of entries, and iterating through both collections produces, in turn, individual elements that compare equal to each other. Elements are dereferenced before being compared. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss void aaaappppppppllllyyyy(void (*fn)(const T*,void*), void* d) const; Applies the user-defined function pointed to by ffffnnnn to every item in the collection. This function must have prototype: void yourfun(const T* a, void* d); Client data may be passed through parameter dddd. PPPPaaaaggggeeee 3333 RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) iterator bbbbeeeeggggiiiinnnn(); const_iterator bbbbeeeeggggiiiinnnn() const; Returns an iterator positioned at the first element of self. void cccclllleeeeaaaarrrr(); Clears the collection by removing all items from self. void cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(); Removes all items from the collection and uses ooooppppeeeerrrraaaattttoooorrrr ddddeeeelllleeeetttteeee to destroy the objects pointed to by those items. bool ccccoooonnnnttttaaaaiiiinnnnssss(const T* a) const; Returns ttttrrrruuuueeee if there exists an element tttt in self that compares equal with ****aaaa, otherwise returns ffffaaaallllsssseeee. bool ccccoooonnnnttttaaaaiiiinnnnssss(bool (*fn)(const T*,void*), void* d) const; Returns ttttrrrruuuueeee if there exists an element tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee, otherwise returns ffffaaaallllsssseeee. ffffnnnn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter dddd. void ddddiiiiffffffffeeeerrrreeeennnncccceeee(const RWTPtrSet<T,C>& s); Sets self to the set-theoretic difference given by ((((sssseeeellllffff ---- ssss)))). Elements from each set are dereferenced before being compared. iterator eeeennnndddd(); const_iterator eeeennnndddd() const; PPPPaaaaggggeeee 4444 RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) Returns an iterator positioned "just past" the last element in self. size_type eeeennnnttttrrrriiiieeeessss() const; Returns the number of items in self. const T* ffffiiiinnnndddd(const T* a) const; If there exists an element tttt in self that compares equal with ****aaaa, returns tttt. Otherwise, returns rrrrwwwwnnnniiiillll. const T* ffffiiiinnnndddd(bool (*fn)(const T*,void*), void* d) const; If there exists an element tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee, returns tttt. Otherwise, returns rrrrwwwwnnnniiiillll. ffffnnnn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter dddd.... bool iiiinnnnsssseeeerrrrtttt(T* a); Adds the item aaaa to the collection. Returns ttttrrrruuuueeee if the insertion is successful, otherwise returns ffffaaaallllsssseeee. The function will return ttttrrrruuuueeee unless the collection already holds an element with an equivalent key. void iiiinnnntttteeeerrrrsssseeeeccccttttiiiioooonnnn(const RWTPtrSet<T,C>& s); Sets self to the intersection of self and ssss. Elements from each set are dereferenced before being compared. bool iiiissssEEEEmmmmppppttttyyyy() const; Returns ttttrrrruuuueeee if there are no items in the collection, ffffaaaallllsssseeee otherwise. bool iiiissssEEEEqqqquuuuiiiivvvvaaaalllleeeennnntttt(const RWTPtrSet<T,C>& s) const; PPPPaaaaggggeeee 5555 RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) Returns ttttrrrruuuueeee if there is set equivalence between self and ssss, and returns ffffaaaallllsssseeee otherwise. bool iiiissssPPPPrrrrooooppppeeeerrrrSSSSuuuubbbbsssseeeettttOOOOffff(const RWTPtrSet<T,C>& s) const; Returns ttttrrrruuuueeee if self is a proper subset of ssss, and returns ffffaaaallllsssseeee otherwise. bool iiiissssSSSSuuuubbbbsssseeeettttOOOOffff(const RWTPtrSet<T,C>& s) const; Returns ttttrrrruuuueeee if self is a subset of ssss or if self is set equivalent to ssss, ffffaaaallllsssseeee otherwise. size_type ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const T* a) const; Returns the number of elements tttt in self that compare equal with ****aaaa. size_type ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(bool (*fn)(T*,void*), void* d); size_type ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(bool (*fn)(const T*,void*), void* d) const; Returns the number of elements tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee. ffffnnnn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter dddd. T* rrrreeeemmmmoooovvvveeee(const T* a); Removes and returns the first element tttt in self that compares equal with ****aaaa. Returns rrrrwwwwnnnniiiillll if there is no such element. T* rrrreeeemmmmoooovvvveeee(bool (*fn)(const T*,void*), void* d); Removes and returns the first element tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd)))))))) is ttttrrrruuuueeee. Returns rrrrwwwwnnnniiiillll if there is no such element. ffffnnnn points to a user-defined tester function which must have prototype: PPPPaaaaggggeeee 6666 RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) bool yourTester(const T* a, void* d); Client data may be passed through par_meter dddd. size_type rrrreeeemmmmoooovvvveeeeAAAAllllllll(const T* a); Removes all elements tttt in self that compares equal with ****aaaa. Returns the number of items removed. size_type rrrreeeemmmmoooovvvveeeeAAAAllllllll(bool (*fn)(const T*,void*), void* d); Removes all elements tttt in self such that the expression ((((((((****ffffnnnn))))((((tttt,,,,dddd))))))))is ttttrrrruuuueeee. Returns the number of items removed. ffffnnnn points to a user-defined tester function which must have prototype: bool yourTester(const T* a, void* d); Client data may be passed through parameter dddd. set<T*, container_comp,allocator>& ssssttttdddd(); const set<T*, container_comp,allocator>& ssssttttdddd() const; Returns a reference to the underlying C++-standard collection that serves as the implementation for self. void ssssyyyymmmmmmmmeeeettttrrrriiiiccccDDDDiiiiffffffffeeeerrrreeeennnncccceeee(const RWTPtrSet<T,C>& s); Sets self to the symmetric difference of self and ssss. Elements from each set are dereferenced before being compared. void UUUUnnnniiiioooonnnn(const RWTPtrSet<T,C>& s); Sets self to the union of self and ssss. Elements from each set are dereferenced before being compared. Note the uppercase "U" in UUUUnnnniiiioooonnnn to avoid conflict with the C++ reserved word. PPPPaaaaggggeeee 7777 RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) RRRRWWWWTTTTPPPPttttrrrrSSSSeeeetttt((((3333CCCC++++++++)))) Related Global Operators RWvostream& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWvostream& strm, const RWTPtrSet<T,C>& coll); RWFile& ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(RWFile& strm, const RWTPtrSet<T,C>& coll); Saves the collection ccccoooollllllll onto the output stream ssssttttrrrrmmmm, or a reference to it if it has already been saved. RWvistream& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTPtrSet<T,C>& coll); RWFile& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTPtrSet<T,C>& coll); Restores the contents of the collection ccccoooollllllll from the input stream ssssttttrrrrmmmm. RWvistream& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWvistream& strm, RWTPtrSet<T,C>*& p); RWFile& ooooppppeeeerrrraaaattttoooorrrr>>>>>>>>(RWFile& strm, RWTPtrSet<T,C>*& p); Looks at the next object on the input stream ssssttttrrrrmmmm and either creates a new collection off the heap and sets pppp to point to it, or sets pppp to point to a previously read instance. If a collection is created off the heap, then you are responsible for deleting it. PPPPaaaaggggeeee 8888